package everyday;

/**
 * @Author: Siantar
 * @Date: 2024-07-06-11:50
 * @Description: 1.0
 */
public class T3101 {
    public long countAlternatingSubarrays(int[] nums) {
        int preNum = -1, sumAdd = 0;
        long sum = 0;
        for (int num : nums) {
            sumAdd = num == preNum ? 1 : sumAdd + 1;
            sum += sumAdd;
            preNum = num;
        }
        return sum;
    }

}
